﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace HomeTask03
{
    public partial class JobPanel : UserControl
    {
        public JobPanel()
        {
            InitializeComponent();
        }


        public JobPanel(String name, String source, String destination, Boolean _isDecrypt) : this()
            
        {
            
            sourcePach.Text = source;
            destinationPach.Text = destination;
            this.Name = name;
            this.isDecrypt = _isDecrypt;
            this.isComplete = false;
            if (isDecrypt) { gbJobPanel.Text = name + " Decrypt"; } else gbJobPanel.Text = name + " Encrypt";
        }


        public string getSourse()
        {
            return sourcePach.Text;
        }

        public string getDestination()
        {
            return destinationPach.Text;
        }


        /// <summary>
        ///set status string color, text and set isComplete property if succeed.
        ///</summary>
        /// <param name="status">Message string</param>
        /// <param name="err">true if error; otherwise, false.</param>
        public void setStatusColor(string status, Boolean err)
        {
            if (err) { lblStatus.ForeColor = Color.Red; } else {
                lblStatus.ForeColor = Color.Green;
                this.isComplete = true;
            }
            lblStatus.Text = status;
        }

        public Boolean isSelected()
        {
            return chbSelected.Checked;
        }

        public void setProgress()
        {
            progressBar.PerformStep();
        }

        public Boolean isComplete { get; set; }
        public Boolean isDecrypt { get; set; }
        public Thread jobThread { get; set; }
    }
}
